package com.zxn.drag;

import android.view.View;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.RecyclerView;

import com.zxn.drag.callback.ItemDragCallback;
import com.zxn.drag.callback.OnItemDragListener;

/**
 * 条目拖拽助手.
 * Created by zxn on 2020/3/19.
 */
public class ItemDragHelper {
    private final ItemTouchHelper mItemTouchHelper;
    private ItemDragCallback mItemDragCallback;


    public ItemDragHelper(View delArea) {
        mItemDragCallback = new ItemDragCallback(delArea);
        mItemTouchHelper = new ItemTouchHelper(mItemDragCallback);
    }

    public void setOnDragListener(OnItemDragListener listener) {
        mItemDragCallback.setDragListener(listener);
    }

    public void attachToRecyclerView(@Nullable RecyclerView recyclerView) {
        mItemTouchHelper.attachToRecyclerView(recyclerView);
    }
}
